package ca.jsbr.as2js_lib.display.canvas.bitmap.imageFilter 
{
	import ca.jsbr.as2js_lib.display.canvas.bitmap.BitmapData;
	import ca.jsbr.as2js_lib.display.utils.Color;
	import js.ImageData;
	/**
	 * ...
	 * @author jsbr [jsricard@lvlstudio.com]
	 */
	public class Tint implements IFilter
	{
		private var _color:Color;
		private var _red:Color;
		private var _green:Color;
		private var _blue:Color;
		private var _tint:Color;
		
		public function Tint() 
		{
			_color = new Color();
			
		}
		
		public function get color():Color 
		{
			return _color;
		}
		
		public function set color(value:Color):void 
		{
			_color = value;
		}
		
		public function get tint():Color 
		{
			return _color.a;
		}
		
		public function set tint(value:Color):void 
		{
			_color.a = value;
		}
		
		public function get blue():Color 
		{
			return _color.b;
		}
		
		public function set blue(value:Color):void 
		{
			_color.b = value;
		}
		
		public function get green():Color 
		{
			return _color.g;
		}
		
		public function set green(value:Color):void 
		{
			_color.g = value;
		}
		
		public function get red():Color 
		{
			return _color.r;
		}
		
		public function set red(value:Color):void 
		{
			_color.r = value;
		}
		
		/* INTERFACE ca.jsbr.as2js_lib.display.canvas.bitmap.imageFilter.IFilter */
		
		public function render(bitmapData:BitmapData):ImageData 
		{
			var len:Number = bitmapData.data.length;
			var data:Array = bitmapData.data
			for (var i:int = 0; i < len; i++)
			{
				data[i] = data[i++] * (1-_color.a) + (_color.r*_color.a);
				data[i] = data[i++] * (1-_color.a) + (_color.g*_color.a);
				data[i] = data[i++] * (1-_color.a) + (_color.b*_color.a);
			}
		}
		
		
		
	}

}